package org.example.library;

import com.google.gson.Gson;
import org.example.methods.Methods;

import java.io.*;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import javax.servlet.http.*;
import javax.servlet.annotation.*;

@WebServlet(value = "/table2")
public class table2 extends HttpServlet {

    public void init() {

    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html");
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");

        PrintWriter out=response.getWriter();
        try {
            HashMap<String,ArrayList<?>> list = Methods.table2();
            Gson gson = new Gson();
            String json = gson.toJson(list);
            out.println(json);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

    }

    public void destroy() {
    }
}